﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.TestManagement.Client;

namespace TFSTools.TFSLibrary.TestManagement
{
    public sealed class TFSTestTeamProject : TFSServerEntity
    {
        #region Initialization

        private ITestManagementTeamProject serverTeamProject;

        internal TFSTestTeamProject(ITFSConnection connection, ITestManagementTeamProject teamProject)
            : base(connection)
        {
            this.serverTeamProject = teamProject;
        }

        #endregion

        internal ITestManagementTeamProject ServerEntity { get { return this.serverTeamProject; } }

        public TFSTestCase GetTestCase(int testCaseId)
        {
            var testCase = this.serverTeamProject.TestCases.Find(testCaseId);
            var tfsTestCase = new TFSTestCase(this.Connection, testCase);
            return tfsTestCase;
        }

        public TFSTestPlan FindTestPlan(int testPlanId)
        {
            var foundPlan = this.serverTeamProject.TestPlans.Find(testPlanId);

            if (foundPlan != null)
            {
                return new TFSTestPlan(this.Connection, foundPlan, this);
            }
            else
            {
                return null;
            }
        }

        public TFSTestPlanCollection GetTestPlans()
        {
            return TFSTestPlanCollection.Create(this);
        }
    }
}
